package com.qfedu.microuser.user.controller;

import com.qfedu.common.core.annotation.NoLogin;
import com.qfedu.common.core.common.R;
import com.qfedu.microuser.user.service.UserService;
import com.qfedu.microuser.user.vo.MyVO;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.util.Map;

/**
 * @author ZLB
 * @version 1.0
 * @description: TODO
 * @date 2025/6/2 20:12
 */
@RestController
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserService userService;

    @GetMapping("/my")
    public R my() {
        MyVO my = userService.my();
        return R.ok(my);
    }

    @NoLogin
    @GetMapping("/invite")
    public R invite(Integer uid) {
        Map<String, Object> invite = userService.invite(uid);
        return R.ok(invite);
    }

    @NoLogin
    @PostMapping("/avatar/upload")
    public R uploadAvatar(MultipartFile file) {
        String path = userService.uploadAvatar(file);
        return R.ok(path);
    }
}
